//package com.wm.adminbackend.config;
//
//import OpenApi;
//import com.wm.adminbackend.anno.Sprint25;
//import SysApi;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Profile;
//import springfox.documentation.builders.ApiInfoBuilder;
//import springfox.documentation.builders.PathSelectors;
//import springfox.documentation.builders.RequestHandlerSelectors;
//import springfox.documentation.service.ApiInfo;
//import springfox.documentation.service.Contact;
//import springfox.documentation.spi.DocumentationType;
//import springfox.documentation.spring.web.plugins.Docket;
//import springfox.documentation.swagger2.annotations.EnableSwagger2;
//
//@Configuration
//@EnableSwagger2
//@Profile({"devnew", "develop", "test", "yingjian"})
//public class Swagger2 {
//
//    @Bean
//    public Docket allApi() {
//        return new Docket(DocumentationType.SWAGGER_2)
//                .groupName("all")
//                .apiInfo(apiInfo())
//                .select()
//                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
//                .paths(PathSelectors.any())
//                .build();
//    }
//
//    @Bean
//    public Docket openApi() {
//        return new Docket(DocumentationType.SWAGGER_2)
//                .groupName("对外API")
//                .apiInfo(apiInfo())
//                .select()
//                .apis(RequestHandlerSelectors.withMethodAnnotation(OpenApi.class))
//                .paths(PathSelectors.any())
//                .build();
//    }
//
//    @Bean
//    public Docket sysApi() {
//        return new Docket(DocumentationType.SWAGGER_2)
//                .groupName("系统API")
//                .apiInfo(apiInfo())
//                .select()
//                .apis(RequestHandlerSelectors.withMethodAnnotation(SysApi.class))
//                .paths(PathSelectors.any())
//                .build();
//    }
//
//    @Bean
//    public Docket Sprint25() {
//        return new Docket(DocumentationType.SWAGGER_2)
//                .groupName("最新API")
//                .apiInfo(apiInfo())
//                .select()
//                .apis(RequestHandlerSelectors.withMethodAnnotation(Sprint25.class))
//                .paths(PathSelectors.any())
//                .build();
//    }
//
//    private ApiInfo apiInfo() {
//        return new ApiInfoBuilder().title("蛙鸣系统管理平台")
//                .description("蛙鸣系统管理平台")
//                .license("MIT")
//                .licenseUrl("http://opensource.org/licenses/MIT")
//                .contact(new Contact("蛙鸣", "http://www.waming-air.cn", "customer@wamingtech.com"))
//                .version("1.0.0")
//                .build();
//    }
//
//}

package com.qingcloud.adminbackend.config;

import com.qingcloud.adminbackend.anno.CloudApi;
import com.qingcloud.adminbackend.anno.EventApi;
import com.qingcloud.adminbackend.anno.ProductApi;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
@EnableOpenApi
public class Swagger2 implements WebMvcConfigurer {

    @Bean
    public Docket allApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("ALL")
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .paths(PathSelectors.any())
                .build();
    }

    @Bean
    public Docket cloudApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("云平台")
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.withMethodAnnotation(CloudApi.class))
                .paths(PathSelectors.any())
                .build();
    }

    @Bean
    public Docket eventApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("事件相关接口")
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.withMethodAnnotation(EventApi.class))
                .paths(PathSelectors.any())
                .build();
    }


    private ApiInfo apiInfo() {
        return new ApiInfoBuilder().title("蛙鸣系统管理平台")
                .description("蛙鸣系统管理平台")
                .license("MIT")
                .licenseUrl("http://opensource.org/licenses/MIT")
                .contact(new Contact("蛙鸣", "http://www.waming-air.cn", "customer@wamingtech.com"))
                .version("1.0.0")
                .build();
    }

}
